package com.sto.stoapp.adapter;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.http.response.upload.ErrorRecordInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

public class ErrorInfoAdapter extends BaseAdapter {

	private List<ErrorRecordInfo> entitys;
	private Context mContext;
	public ErrorInfoAdapter(Context context,List<ErrorRecordInfo> entitys){
		this.mContext=context;
		this.entitys=entitys;
	}
	@Override
	public int getCount() {
	
		return entitys.size();
	}

	@Override
	public Object getItem(int position) {
	
		return entitys.get(position);
	}

	@Override
	public long getItemId(int position) {
	
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		Holder holder;
		if (view == null) {
			holder = new Holder();
			view = LayoutInflater.from(mContext).inflate(
					R.layout.error_info_item, null);
			holder.code = (TextView) view
					.findViewById(R.id.code);
			holder.error = (TextView) view
					.findViewById(R.id.error);
			view.setTag(holder);
		} else {
			holder = (Holder) view.getTag();
		}
		holder.code.setText(entitys.get(position).respWaybillNo);
		holder.error.setText(entitys.get(position).respErrorDescription);
		return view;
	}
	class Holder {
		TextView code;
		TextView error;
	}}